package springapp.service;

import java.util.List;

import org.springframework.beans.factory.annotation.Required;

import springapp.domain.Product;

public class SimpleProductManager implements ProductManager {

	private List<Product> products;

	public List<Product> getProducts() {
		return products;
	}

	public void increasePrice(int percentage) {
		if (products != null) {
			for (Product product : products) {
				double newPrice = product.getPrice().doubleValue()
						* (100 + percentage) / 100;
				product.setPrice(newPrice);
			}
		}else{
			System.out.println("TEST:SimpleProductManager.increasePrice: productlist is null");
		}
	}

	@Required
	public void setProducts(List<Product> products) {
		if(products!=null){
			this.products = products;
		}else{
			System.out.println("TEST:SimpleProductManager.setProducts: product is null");
		}
		System.out.println("TEST:SimpleProductManager.setProducts");
		for (Product product : products) {		
			System.out.println("TEST:"+ product.getDescription());
		}
		
	}

}
